<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path1 = request.getContextPath();
	String basePath1 = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path1 + "/";

	String pageUrl = request.getAttribute(
	"javax.servlet.forward.servlet_path").toString()
	+ "?";
	String method = request.getMethod().toUpperCase();
	//System.out.println(method);
	if ("GET".equals(method) && null!=request.getQueryString()) {
		String[] values = request.getQueryString().split("&");
		for (int i = 0; i < values.length; i++) {
	if (null != values[i]
			&& values[i].length() > 0
			&& !("pageNum").equals(values[i].substring(0,
					values[i].indexOf("=")))) {
		pageUrl += values[i] + "&";
	}
		}
	} else if ("POST".equals(method) && null!=request.getParameterNames()) {
		Enumeration<String> pageEnum = request.getParameterNames();
		while (pageEnum.hasMoreElements()) {
	String paramName = (String) pageEnum.nextElement();
	String[] values = request.getParameterValues(paramName);
	for (int i = 0; i < values.length; i++) {
		if (null != values[i] && values[i].length() > 0
				&& !("pageNum").equals(paramName) && pageUrl.indexOf(paramName+"=")==-1) {
			pageUrl += paramName + "=" + values[i] + "&";
		}
	}
		}
	}
	pageUrl = pageUrl.substring(1);
%>
<script type="text/javascript">
	/* 分页 ly */
	function pageJs(page, path) {
		ch = page.split("?");
		len = ch[0].length;
		var actions = path + ch[0];
		dates = ch[1].split("&");
		var html = "";
		for (var i = 0; i < dates.length; i++) {
			var date = dates[i];

			d = date.split("=");
			if (date.substring(d[0].length + 1, date.length) != "") {
				html = html + '<input type="hidden" name="' + d[0]
						+ '" value="'
						+ date.substring(d[0].length + 1, date.length) + '" />';
			}
		}

		$('#page').attr("action", actions);
		$('#page').html(html);
		var s = $('#page').html();
		$("#page").submit();
	}
</script>
<form id='page' method='post' action='' name='form'></form>
<table class="gridtable" style="width:100%;text-align: center;">
	<tr>
		<c:if test="${pageInfo.hasPreviousPage}">
			<td><a
				onclick='pageJs("<%=pageUrl%>&pageNum=1","<%=basePath1%>")' href="#">首页</a></td>
		</c:if>
		<c:if test="${pageInfo.hasPreviousPage}">
			<td><a
				onclick='pageJs("<%=pageUrl%>&pageNum=${pageInfo.prePage}","<%=basePath1%>")'
				href="#}">前一页</a></td>
		</c:if>
		<c:forEach items="${pageInfo.navigatepageNums}" var="nav">
			<c:if test="${nav == pageInfo.pageNum}">
				<td style="font-weight: bold;">${nav}</td>
			</c:if>
			<c:if test="${nav != pageInfo.pageNum}">
				<td><a
					onclick='pageJs("<%=pageUrl%>&pageNum=${nav}","<%=basePath1%>")'
					href="#">${nav}</a></td>
			</c:if>
		</c:forEach>
		<c:if test="${pageInfo.hasNextPage}">
			<td><a
				onclick='pageJs("<%=pageUrl%>&pageNum=${pageInfo.nextPage}","<%=basePath1%>")'
				href="#">下一页</a></td>
		</c:if>
		<c:if test="${pageInfo.hasNextPage}">
			<td><a
				onclick='pageJs("<%=pageUrl%>&pageNum=${pageInfo.pages}","<%=basePath1%>")'
				href="#">末页</a></td>
		</c:if>
		&nbsp; 共 ${pageInfo.pages} 页 ${pageInfo.total} 条记录
	</tr>
</table>